package com.job.yangshida.homework0715;

import java.util.Arrays;

/**
 * @author 杨士达
 * @version 1.0
 * @since 2022-07-16 13:46:54
 */
public class Palindrome {
    //找出5到6位回文数字,和为12
    public static void main(String[] args) {
        for (int i = 10000; i < 100000; i++) {
            isPalindrome(i);
        }
    }

    public static boolean isPalindrome(int n) {
        String s = n + "";
        //byte[] b=s.getBytes();
        //System.out.println(Arrays.toString(b));
        int sum =0;
        for (int i = 0; i <= s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
                return false;//不是回文
            }
            if (i != s.length() - 1 - i) {
                int i1=Integer.parseInt(s.charAt(i)+"");
                sum = sum + 2 * i1;
               // sum=sum+2*b[i];
            } else {
                int i1=Integer.parseInt(s.charAt(i)+"");
                sum =sum+ i1;
            }
        }
        if (sum == 12) {
            System.out.println(n);
            return true;
        }
        return false;

    }

}